window.onload=function(){

$(function(){
    $.getJSON('../json/collectMenu.json',function(response){
        var recordCount=0   //总记录数
        var pageSize=response.length      //每页显示记录数
        var pageCount=0     //总页数
        var pageIndex=0     //当前页的索引值
    var strHTML=''
    var strHTML1=''
    for(var i=0 ; i<pageSize ; i++){
        if(response[i]){
            strHTML+=`<li>
                        <a href="" class="cook-img">
                            <img src="${response[i].image}" alt="">
                        </a>
                        <br/>
                        <a href="">${response[i].name}</a>
                        <p>
                            <span class="glyphicon glyphicon-eye-open"></span>
                            <span>${response[i].read}</span>
                            <span class="glyphicon glyphicon-star"></span>
                            <span>${response[i].collect}</span>
                        </p>
                    </li> `
        }
    }
    $("#products").html(strHTML)

 
    var cails=[]
    if(localStorage['caidan']){
       cails=JSON.parse(localStorage['caidan'])
       for(var i=0;i<cails.length;i++){
            strHTML1 +=`<li>
                            <a href="" class="cook-img">
                                <img src="${response[i].image}" alt="">
                            </a>
                            <br/>
                            <a href="">${cails[i].food}</a>
                            <p>
                                <img src="images/s01.png" alt="">
                                <span>0次</span>
                                <img src="images/s02.png" alt="">
                                <span>1次</span>
                            </p>
                        </li> `
        }
        $("#products").html(strHTML).append(strHTML1)
    }
    })
})
}
